<template>
  <div class="home">
    <van-search
      v-model="search"
      placeholder="请输入搜索关键词"
      show-action
      shape="round"
      @search="onSearch"
    >
      <div slot="action" @click="onSearch">搜索</div>
      <div slot="label">成都</div>
    </van-search>
    <van-swipe :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in images" :key="item">
        <img :src="item" class="swipe_img">
      </van-swipe-item>
    </van-swipe>
    <div class="tip_list">
      <router-link to="/roomFriends">
        <van-button plain type="primary">房友圈</van-button>
      </router-link>
      <router-link to="/questionAnswer">
        <van-button plain type="primary">房问答</van-button>
      </router-link>
      <router-link to="/senior">
        <van-button plain type="primary">房资深</van-button>
      </router-link>
      <router-link to="/listDtalis">
        <van-button plain type="primary">新房团购</van-button>
      </router-link>
    </div>
    <div class="title flex_space">
      <div class="mix_title">房市论坛</div>
      <div class="flex_start">
        <span class="min_font">更多</span>
        <van-icon name="arrow" size="15"></van-icon>
      </div>
    </div>
    <div @click="goBBSInfo(item.id)" class="panel-list" v-for="item in  list " :key="item.id">
      <div class="card_header">
        <div class="flex_start">
          <div>
            <van-tag mark type="danger" v-if="item.tag == 1">重磅</van-tag>
            <van-tag mark type="danger" v-if="item.tag == 0">热门</van-tag>
          </div>
          <div class>{{item.title}}</div>
        </div>
        <img v-if="item.img" :src="item.img" width="100" height="50">
      </div>
      <div class="card_header">
        <div class="min-size">{{item.name}}</div>
        <div class="min-size">
          <span>浏览{{item.browseNum}}人</span>
          <span>评论{{item.reviewNum}}人</span>
        </div>
      </div>
    </div>
    <div class="title flex_space">
      <div class="mix_title">新房团购</div>
      <div class="flex_start">
        <span class="min_font">更多</span>
        <van-icon name="arrow" size="15"></van-icon>
      </div>
    </div>
    <div class="list_groups">
      <div v-for="item in roomList " :key="item.id" class="card_list">
        <div class="van-card flex_start">
          <img :src="item.img">
          <div class="card_right">
            <div class="flex_space">
              <div class="title_room">{{item.title}}</div>
              <div class="desc">{{item.address}}</div>
            </div>
            <div class="flex_space">
              <div class="desc">
                {{item.distance}}m
                <sup>2</sup>
              </div>
              <div class="price">
                <span v-if="item.status == 2" style="font-size:12px">团购</span>
                {{item.price}}元
                <span v-if="item.status == 0">/年</span>
                <span v-if="item.status == 1">/月</span>
              </div>
            </div>
            <div class="desc">{{item.desc}}</div>
            <div class="tag_group flex_start">
              <van-tag plain type="danger" v-for="tag in item.tag " :key="tag">{{tag}}</van-tag>
            </div>
            <div class="flex_space">
              <div class="desc">浏览：{{item.browseNum}}人</div>
              <div class="desc">评论：{{item.signNum}}人</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="title flex_space">
      <div class="mix_title">二手房精选</div>
      <div class="flex_start">
        <span class="min_font">更多</span>
        <van-icon name="arrow" size="15"></van-icon>
      </div>
    </div>
    <div class="list_groups">
      <div v-for="item in usedRoom " :key="item.id" class="card_list">
        <div class="flex_start van-card">
          <img :src="item.img">
          <div class="card_right">
            <div class="flex_space">
              <div class="title_room">{{item.title}}</div>
              <div class="desc">{{item.address}}</div>
            </div>
            <div class="flex_space">
              <div class="desc">
                {{item.distance}}m
                <sup>2</sup>
              </div>
              <div class="price">
                <span v-if="item.status == 2" style="font-size:12px">团购</span>
                {{item.price}}元
                <span v-if="item.status == 0">/年</span>
                <span v-if="item.status == 1">/月</span>
              </div>
            </div>
            <div class="desc">{{item.desc}}</div>

            <div class="tag_group flex_start">
              <van-tag plain type="danger" v-for="tag in item.tag " :key="tag">{{tag}}</van-tag>
            </div>
            <div class="flex_space">
              <div class="desc">浏览：{{item.browseNum}}人</div>
              <div class="desc">评论：{{item.signNum}}人</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import {
  Tabbar,
  TabbarItem,
  Tag,
  Swipe,
  SwipeItem,
  Search,
  Icon,
  Lazyload,
  Button
} from 'vant'

export default {
  components: {
    [Tabbar.name]: Tabbar,
    [TabbarItem.name]: TabbarItem,
    [Swipe.name]: Swipe,
    [SwipeItem.name]: SwipeItem,
    [Tag.name]: Tag,
    [Icon.name]: Icon,
    [Search.name]: Search,
    [Lazyload.name]: Lazyload,
    [Button.name]: Button
  },
  data() {
    return {
      search: '',
      images: [
        'https://img.yzcdn.cn/public_files/2017/10/24/e5a5a02309a41f9f5def56684808d9ae.jpeg',
        'https://img.yzcdn.cn/public_files/2017/10/24/1791ba14088f9c2be8c610d0a6cc0f93.jpeg'
      ],
      list: [
        {
          id: '0',
          title: '大多数人们喜欢的户型有哪些?',
          name: '@测试',
          img:
            'https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D790/sign=1cf755a396ef76c6d0d2f922ad17fdf6/b03533fa828ba61e51f94fad4734970a304e5919.jpg',
          browseNum: 50,
          reviewNum: 20,
          totalAll: 666,
          tag: 1 //重磅
        },
        {
          id: '1',
          title: '学区房到底有什么好处?',
          name: '@张某某',
          img:
            'https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D790/sign=1cf755a396ef76c6d0d2f922ad17fdf6/b03533fa828ba61e51f94fad4734970a304e5919.jpg',

          browseNum: 150,
          reviewNum: 120,
          totalAll: 999,
          tag: 0 //热门
        },
        {
          id: '2',
          title: '下一个学区房在哪里?',
          img:
            'https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D790/sign=1cf755a396ef76c6d0d2f922ad17fdf6/b03533fa828ba61e51f94fad4734970a304e5919.jpg',

          name: '@大磊',
          browseNum: 150,
          reviewNum: 120,
          totalAll: 999,
          tag: 0 //热门
        }
      ],
      roomList: [
        {
          id: 0,
          img:
            'https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/c0%3Dbaike116%2C5%2C5%2C116%2C38/sign=c1569f7c4734970a537e187df4a3baad/d788d43f8794a4c2149bb07808f41bd5ad6e392c.jpg',
          title: '花样年华二期',
          tag: ['地铁旁', '学区房', '公园房'],
          address: '高新区',
          desc: '三室二厅一卫',
          browseNum: 220,
          signNum: 222,
          mark: '二手房',
          distance: '171.11',
          price: '8000',
          status: 0 //年
        }
      ],
      usedRoom: [
        {
          id: 0,
          img:
            'https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/c0%3Dbaike116%2C5%2C5%2C116%2C38/sign=c1569f7c4734970a537e187df4a3baad/d788d43f8794a4c2149bb07808f41bd5ad6e392c.jpg',
          title: '花样年华二期',
          tag: ['地铁旁', '学区房', '公园房'],
          address: '高新区',
          desc: '三室二厅一卫',
          browseNum: 220,
          signNum: 222,
          mark: '二手房',
          distance: '171.11',
          price: '8000',
          status: 0 //年
        }
      ]
    }
  },
  methods: {
    onSearch() {},
    goBBSInfo(id) {
      this.$router.push({
        path: '/post',
        query: {
          id: id
        }
      })
    }
  }
}
</script>
<style lang="less">
.home {
  .swipe_img {
    width: 100%;
    height: 180px;
  }
  .tip_list {
    padding: 10px 10px;
    box-sizing: border-box;
    background-color: #fff;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
  }
  .title {
    padding: 10px 10px;
    box-sizing: border-box;
    .min_title {
      font-size: 14px;
    }
    .min_font {
      font-size: 12px;
    }
  }
  .panel-list {
    margin-bottom: 5px;
    background-color: #fff;
    border: 1px solid #e5e5e5;
    padding: 10px 10px;
    box-sizing: border-box;
    .card_header {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
    }
    .card_footer {
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      font-size: 14px;
      padding: 10px 0;
      box-sizing: border-box;
      border-top: 1px solid #e5e5e5;
      margin-top: 5px;
    }
  }
  .list_groups {
    .card_list {
      margin-bottom: 10px;
      .van-card {
        position: static;
        border: 1px solid #e5e5e5;
        background-color: #ffffff;
        padding: 15px 15px;
        box-sizing: border-box;
        img {
          width: 140px;
          height: 100px;
        }
        .mark {
          position: absolute;
          left: 20px;
          width: 30px;
          height: 15px;
          color: #ffffff;
          font-size: 10px;
        }
        .card_right {
          width: 100%;
          margin-left: 15px;
        }
        .desc {
          color: #9a9b9c;
          margin-top: 2px;
          font-size: 12px;
        }
        .price {
          font-size: 16px;
          color: red;
        }
        .tag_group {
          margin-top: 5px;
          margin-bottom: 5px;
        }
        .van-tag {
          margin-right: 5px;
        }
      }
    }
  }
}
.flex_space {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
.flex_start {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
}

.min-size {
  font-size: 12px;
  color: #e3e3e3;
  margin-top: 10px;
}
</style>
